package com.sh.personnel.security.config.handler;

import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 无权限访问返回的信息
 * @author 林思浩
 * @date 2020/01/05 18:40
 */
@Component
public class MyAccessDeniedHandler extends MyCustomHandler implements AccessDeniedHandler {

    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) throws IOException {
        this.responseJson(HttpServletResponse.SC_FORBIDDEN, "您没有访问权限！", response); // 403
    }

}
